package com.netty.esc.Interceptor.aspect;

import com.netty.esc.common.global.UserCache;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


@Aspect
@Component
@Slf4j(topic = "esc-im 线程缓存清理后置aop-------")
@Order()
public class LocalCacheCleanUpImpl {
    /**
     * 拦截所有controller方法，在执行完毕后清理掉用户信息缓存
     */
    @Pointcut("execution(public * com.netty.esc.http.controller..*.*(..))")
    public void pointCut(){}

    @After("pointCut()")
    public void doAfter(JoinPoint joinPoint){
        if (UserCache.getCurrentUser()!=null){
            UserCache.remove();
            log.info("用户缓存信息清理完成..");
        }
    }


}
